from frame_work.logger import Logger
from configparser import ConfigParser
from frame_work.setting import config_Path

logger = Logger(__name__).get_logger()


class ReadConfig(object):
    def __init__(self):
        self.config = ConfigParser()
        self.config.read(config_Path, encoding='utf-8')
        # self.logger = Logger(logger="read_config").get_logger()

    def get_url(self, name):  # 废弃 整合到yaml文件中
        """
        获取config.ini中[url]中数据
        :param name:
        :return:
        """
        value = self.config.get("url", name)
        logger.debug("获取URL: %s ==> %s " % (name, value))
        return value

    def get_timer_url(self, name):  # 废弃 整合到yaml文件中
        """
        获取config.ini中[Timer_Url]中数据
        :param name:
        :return:
        """
        value = self.config.get("Timer_Url", name)
        logger.debug("获取定时器执行地址: %s ==> %s " % (name, value))
        return value

    def get_order_url(self, name):
        """
        获取config.ini中[order_url]中数据
        :param name:
        :return:
        """
        value = self.config.get("order_url", name)
        logger.debug("获取Order_URL: %s ==> %s " % (name, value))
        return value

    def get_database_info(self, name):
        """
        获取config.ini中[dataBase]中数据
        :param name:
        :return:
        """
        value = self.config.get("dataBase", name)
        logger.debug("获取数据库连接信息: %s ==> %s " % (name, value))
        return value

    def get_tfx_database_info(self, name):
        """
        获取config.ini中[dataBase]中数据
        :param name:
        :return:
        """
        value = self.config.get("tfx_dataBase", name)
        logger.debug("获取tfx数据库连接信息: %s ==> %s " % (name, value))
        return value

    def get_email_info(self, name):
        """
        获取config.ini中[email]中数据
        :param name:
        :return:
        """
        value = self.config.get("email", name)
        logger.debug("获取邮件连接信息: %s ==> %s " % (name, value))
        return value

    def get_domain(self, name):  # 废弃 整合到yaml文件中
        """
        获取config.ini中[domain]中数据
        :param name:
        :return:
        """
        value = self.config.get("domain", name)
        logger.debug("获取domain信息: %s ==> %s " % (name, value))
        return value

    def get_browser_name(self, name):
        """
        获取浏览器
        :param name:
        :return:
        """
        value = self.config.get("browserType", name)
        logger.debug("获取浏览器信息: %s ==> %s " % (name, value))
        return value

    def get_pwd(self, name):
        """
        获取密码
        :param name:
        :return:
        """
        value = self.config.get("Password", name)
        logger.debug("获取密码: %s ==> %s " % (name, value))
        return value

    def get_version(self, name):  # 废弃 整合到yaml文件中
        """
        获取最新app版本号
        :param name:
        :return:
        """
        value = self.config.get("version", name)
        logger.debug("获取最新app版本号: %s ==> %s " % (name, value))
        return value


global_config = ReadConfig()

if __name__ == '__main__':
    # config = ReadConfig()
    print(global_config.get_pwd('payPwd'))
